module one {
	export class LanguageUtils {
		public constructor() {
		}

		private languages: { [id: number]: string };
		setLanguage(id: number): void {
			this.languages = RES.getRes(`language${id}_json`);
		}

		public getAreaStatement(id: number, areaID: number, ...args): string {
			let statement = this.languages["normal"][id];
			if (this.languages[areaID] && this.languages[areaID][id]) {
				statement = this.languages[areaID][id];
			}

			if (args == null) {
				return statement;
			}

			for (let i: number = 0; i < args.length; i++) {
				let reg = new RegExp('<' + i + '>', "g");
				statement = statement.replace(reg, args[i]);
			}

			return statement;
		}

		public getStatement(id: number, ...args): string {
			let statement = this.languages["normal"][id];

			if (args == null) {
				return statement;
			}

			for (let i: number = 0; i < args.length; i++) {
				let reg = new RegExp('<' + i + '>', "g");
				statement = statement.replace(reg, args[i]);
			}

			return statement;
		}
	}

	export var langUtils = new LanguageUtils();
}